/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package issr.controller;

import issr.entity.Utente;
import issr.misc.Labels;
import issr.persistence.Database;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.ejb.Stateless;

/**
 *
 * @author Soulreaver
 */
@WebService(serviceName = "ControlloreLogin")
@Stateless()
public class ControlloreLogin {

    private Database db = Database.getInstance();

    /**
     * Web service operation
     */
    @WebMethod(operationName = "loginUtente")
    public Utente loginUtente(@WebParam(name = "login") String login, @WebParam(name = "password") String password) {
        Utente user = db.caricaUtente(login, password);
        if (user != null) {
            db.aggiungiEntry(
                    user,
                    Labels.LOGIN);
            return user;
        } else {
            return null;
        }
    }
}
